// 动态路由配置文件
import type { RouteRecordRaw } from 'vue-router'

export const dynamicRoutes: RouteRecordRaw[] = [
  // 仪表盘
  {
    path: 'dashboard',
    name: 'Dashboard',
    component: () => import('@/views/Dashboard.vue'),
    meta: { title: '仪表盘', icon: 'fa fa-dashboard' }
  },

  {
    path: 'user',
    name: 'User',
    redirect: '/user/usermanagement',
    meta: { title: '用户管理', icon: 'fa fa-users' },
    children: [
      {
        path: 'usermanagement',
        name: 'UserManagement',
        component: () => import('@/views/user/UserManagement.vue'),
        meta: { title: '用户管理', icon: 'fa fa-user' }
      },
      {
        path: 'groups',
        name: 'UserGroups',
        component: () => import('@/views/user/UserGroupManagement.vue'),
        meta: { title: '用户组管理', icon: 'fa fa-users' }
      },
      {
        path: 'roles',
        name: 'UserRoles',
        component: () => import('@/views/user/RoleManagement.vue'),
        meta: { title: '角色管理', icon: 'fa fa-user-tag' }
      },
      {
        path: 'menu-permission',
        name: 'UserMenuPermission',
        component: () => import('@/views/user/MenuPermissionManagement.vue'),
        meta: { title: '菜单权限管理', icon: 'fa fa-key' }
      }
    ]
  },

  // CMDB资产管理
  {
    path: 'cmdb',
    name: 'Cmdb',
    redirect: '/cmdb/hosts',
    meta: { title: 'CMDB资产管理', icon: 'fa fa-database' },
    children: [
      {
        path: 'hosts',
        name: 'CmdbHosts',
        component: () => import('@/views/hosts/HostManagement.vue'),
        meta: { title: '主机管理', icon: 'fa fa-server' }
      },
      {
        path: 'connections',
        name: 'CmdbConnections',
        component: () => import('@/views/connections/Index.vue'),
        meta: { title: '连接主机', icon: 'fa fa-terminal' }
      },
      {
        path: 'hostgroups',
        name: 'CmdbHostgroups',
        component: () => import('@/views/hostgroups/Index.vue'),
        meta: { title: '主机组管理', icon: 'fa fa-object-group' }
      },
      {
        path: 'hosttypes',
        name: 'CmdbHosttypes',
        component: () => import('@/views/hosts/HostTypeManagement.vue'),
        meta: { title: '主机类型管理', icon: 'fa fa-tags' }
      }
    ]
  },

  // 用户管理
  {
    path: 'user',
    name: 'User',
    redirect: '/user/usermanagement',
    meta: { title: '用户管理', icon: 'fa fa-users' },
    children: [
      {
        path: 'usermanagement',
        name: 'UserManagement',
        component: () => import('@/views/user/UserManagement.vue'),
        meta: { title: '用户管理', icon: 'fa fa-user' }
      },
      {
        path: 'groups',
        name: 'UserGroups',
        component: () => import('@/views/user/UserGroupManagement.vue'),
        meta: { title: '用户组管理', icon: 'fa fa-users' }
      },
      {
        path: 'roles',
        name: 'UserRoles',
        component: () => import('@/views/user/RoleManagement.vue'),
        meta: { title: '角色管理', icon: 'fa fa-user-tag' }
      },
      {
        path: 'menu-permission',
        name: 'UserMenuPermission',
        component: () => import('@/views/user/MenuPermissionManagement.vue'),
        meta: { title: '菜单权限管理', icon: 'fa fa-key' }
      }
    ]
  },

  // Ansible管理
  {
    path: 'ansible',
    name: 'Ansible',
    redirect: '/ansible/inventory',
    meta: { title: 'Ansible管理', icon: 'fa fa-tasks' },
    children: [
      {
        path: 'config',
        name: 'AnsibleConfig',
        component: () => import('@/views/ansible/SimpleConfig.vue'),
        meta: { title: '配置管理', icon: 'fa fa-cogs' }
      },
      {
        path: 'inventory',
        name: 'AnsibleInventory',
        component: () => import('@/views/ansible/SimpleInventory.vue'),
        meta: { title: 'Inventory管理', icon: 'fa fa-list-alt' }
      },
      {
        path: 'adhoc',
        name: 'AnsibleAdhoc',
        component: () => import('@/views/ansible/SimpleAdhoc.vue'),
        meta: { title: 'Ad-hoc执行', icon: 'fa fa-play' }
      },
      {
        path: 'playbook',
        name: 'AnsiblePlaybook',
        component: () => import('@/views/ansible/PlaybookExecution.vue'),
        meta: { title: 'Playbook执行', icon: 'fa fa-play-circle' }
      },
      {
        path: 'credentials',
        name: 'AnsibleCredentials',
        component: () => import('@/views/ansible/CredentialManagement.vue'),
        meta: { title: '凭据管理', icon: 'fa fa-shield' }
      }
    ]
  },

  // 历史记录
  {
    path: 'history',
    name: 'History',
    redirect: '/history/ssh-audit',
    meta: { title: '历史记录', icon: 'fa fa-history' },
    children: [
      {
        path: 'ssh-audit',
        name: 'HistorySSHAudit',
        component: () => import('@/views/history/SSHAudit.vue'),
        meta: { title: 'SSH日志审计', icon: 'fa fa-terminal' }
      },
      {
        path: 'ansible-audit',
        name: 'HistoryAnsibleAudit',
        component: () => import('@/views/history/AnsibleAudit.vue'),
        meta: { title: 'Ansible日志审计', icon: 'fa fa-tasks' }
      },
      {
        path: 'sql-audit',
        name: 'HistorySQLAudit',
        component: () => import('@/views/history/SqlAudit.vue'),
        meta: { title: 'SQL日志审计', icon: 'fa fa-database' }
      }
    ]
  },

  // 系统管理
  {
    path: 'system',
    name: 'System',
    redirect: '/system/menu-management',
    meta: { title: '系统管理', icon: 'fa fa-cogs' },
    children: [
      {
        path: 'monitoring',
        name: 'SystemMonitoring',
        component: () => import('@/views/monitoring/Index.vue'),
        meta: { title: '监控中心', icon: 'fa fa-line-chart' }
      },

      {
        path: 'menu-management',
        name: 'SystemMenuManagement',
        component: () => import('@/views/system/MenuManagement.vue'),
        meta: { title: '菜单管理', icon: 'fa fa-list' }
      },
      {
        path: '系统备份',
        name: 'SystemBackup',
        component: () => import('@/views/generated/Systembackup.vue'),
        meta: { title: '系统备份', icon: 'fa fa-database' }
      }
    ]
  }
]

export default dynamicRoutes
